package com.htandroid.htandroid.aty;

import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v7.app.AlertDialog;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;

import com.ab.soap.AbSoapListener;
import com.ab.soap.AbSoapParams;
import com.ab.soap.AbSoapUtil;
import com.ab.util.AbDialogUtil;
import com.ab.util.AbToastUtil;
import com.ab.view.ioc.AbIocView;
import com.htandroid.htandroid.R;
import com.htandroid.htandroid.entity.CgglCgList;
import com.htandroid.htandroid.sys.Base_cggl_choose;
import com.htandroid.htandroid.sys.Basenvo;
import com.htandroid.htandroid.sys.InstorageURL;
import com.htandroid.htandroid.sys.User;
import com.htandroid.htandroid.webservice.BuildCgglscshXMLService;
import com.htandroid.htandroid.webservice.abXMLCgglscshlist;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.htandroid.htandroid.constance.ConstanceServer.BaseUrl_New;

/**
 * Created by lkp on 2015/11/29.
 */
public class Cggl_sh_index extends Base_cggl_choose {
    private ArrayList<CgglCgList> cgglCgList;
    private ArrayList<CgglCgList> isSelectList = new ArrayList<CgglCgList>();
    public String excelPath;
    public String imgPath;
    double amount = 0.00;
    private ArrayAdapter<String> adapter_shck;//收货仓库下拉列表
    private ArrayAdapter<String> adapter_rklb;//入库类别下拉列表
    ArrayList<String> list_shck = new ArrayList<String>();
    ArrayList<String> list_cwhcode = new ArrayList<String>();
    ArrayList<String> list_rklb = new ArrayList<String>();
    ArrayList<String> list_crdcode = new ArrayList<String>();
    ArrayList<Map<String, Object>> dataListForInit = null;
    Map<String, Object> dialogdata = null;
    String shid = "";
    String yssl = "";
    String sl = "";
    String shck_name = "";
    String cwhcode = "";
    String rklb_name = "";
    String crdcode = "";
    String taxtype = "";
    boolean isbegin = false;

    @AbIocView(id = R.id.chooseall_cb)
    CheckBox chooseall_cb;
    @AbIocView(id = R.id.edit_shid)
    EditText edit_shid;
    @AbIocView(id = R.id.spinner_shck)
    Spinner spinner_shck;
    @AbIocView(id = R.id.spinner_rklb)
    Spinner spinner_rklb;
    //@AbIocView(id = R.id.tv_cgdorder)
    TextView tv_cgdorder;

    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setAbContentView(R.layout.layout_cggl_sh);
        initview("订单生成收货");
        tv_cgdorder = (TextView) findViewById(R.id.tv_cgdorder);
        shid = edit_shid.getText().toString();
        initview2();
        getdata(0);

        final Runnable runnable = new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    getWareHouse();
                    handler.sendMessage(handler.obtainMessage(0));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };

        try {
            //开启线程
            new Thread(runnable) {
                @Override
                public void run() {
                    Looper.prepare();
                    new Handler().post(runnable);
                    Looper.loop();
                }
            }.start();
            //handler与线程之间的通信及数据处理
            handler = new Handler() {
                public void handleMessage(Message msg) {
                    if (msg.what == 0) {
                        if (isbegin == true) {
                            adapter_shck.notifyDataSetChanged();
                        } else {
                            new Handler().post(runnable);
                            adapter_shck.notifyDataSetChanged();
                        }
                    }
                }
            };
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //初始化2
    @Override
    public void initview2() {
        adapter_shck = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list_shck);
        adapter_rklb = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list_rklb);
        adapter_shck.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        adapter_rklb.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner_shck.setAdapter(adapter_shck);
        spinner_rklb.setAdapter(adapter_rklb);
        list_crdcode.add(myApplication.getGs_option1().getShd_rdincode());
        list_rklb.add(myApplication.getGs_option1().getShd_rdinname());
        adapter_rklb.notifyDataSetChanged();

        spinner_shck.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Spinner mcacc = (Spinner) parent;
                shck_name = mcacc.getSelectedItem().toString();
                for (int j = 0; j < list_cwhcode.size(); j++) {
                    if (list_shck.get(j).equals(shck_name)) {
                        //设置tag
                        mcacc.setTag(list_cwhcode.get(j));
                    }
                }
                cwhcode = mcacc.getTag().toString();
                TextView v1 = (TextView) view;
                v1.setTextColor(Color.WHITE);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        spinner_rklb.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Spinner mcacc = (Spinner) parent;
                rklb_name = mcacc.getSelectedItem().toString();
                for (int j = 0; j < list_crdcode.size(); j++) {
                    if (list_rklb.get(j).equals(rklb_name)) {
                        //设置tag
                        mcacc.setTag(list_crdcode.get(j));
                    }
                }
                crdcode = mcacc.getTag().toString();
                TextView v1 = (TextView) view;
                v1.setTextColor(Color.WHITE);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        spinner_rklb.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                getRdStyle();
                return false;
            }
        });

//        btn_share.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                newList = new ArrayList<MrqgdDjList>();
//                for (int i = 0; i < mrqgdlists.size(); i++) {
//                    if (sa.getIsSelected().get(i) == true) {
//                        newList.add(mrqgdlists.get(i));
//                    }
//                }
//                excelPath = getExcelDir() + File.separator + "请购叫货" + ".xls";
//                ExcelPurchase_cfqgqd cfqgqd = new ExcelPurchase_cfqgqd(Cggl_qg_index.this, excelPath, newList, listtype);
//                if (newList.size() == 0) {
//                    AbToastUtil.showToast(getApplicationContext(), "请选择要分享的数据");
//                } else {
//                    OnekeyShare oks = new OnekeyShare();
//                    oks.setTitle("请购叫货" + ".xls");
//                    oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {
//                        @Override
//                        public void onShare(Platform platform,
//                                            Platform.ShareParams paramsToShare) {
//                            // TODO Auto-generated method stub
//                            if (platform.getName().equals("Wechat")) {
//                                paramsToShare.setShareType(Platform.SHARE_FILE);
//                            }
//                        }
//                    });
//                    imgPath = getExcelDir() + File.separator + "excel.png";
//                    oks.setImagePath(imgPath);
//                    oks.setFilePath(excelPath);
//                    oks.show(getApplicationContext());
//                }
//            }
//        });

//        Intent intent = getIntent();// 创建Intent对象
//        //获取传递的对象参数
//        mrqgds = (MrqgdDjList) getIntent().getSerializableExtra("mrqgds");

        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                linechoose("m", Integer.valueOf("" + id), adatperDataList);

                final View adapterView = view;
                final int i = position;
                ImageView edit_iv = (ImageView) adapterView.findViewById(R.id.edit_iv);
                edit_iv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //点击进入编辑状态
                        showMyDialog(i);
                    }
                });
                if (sa.getIsSelected().get(i) == true) {
//                if (adatperDataList.get(position).get("" + position).toString() == "true") {
                    isSelectList.add(cgglCgList.get(position));
                } else {
                    isSelectList.remove(cgglCgList.get(position));
                }
                amount = sa.sumAmount(adatperDataList);
                if (amount == 0.00) {
                    tv_cgdorder.setText("生成");
                } else {
                    tv_cgdorder.setText("生成（含税金额：" + amount + "元）");
                }
            }
        });

        chooseall_cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView,
                                         boolean isChecked) {
                // TODO Auto-generated method stub
                isSelectList = new ArrayList<CgglCgList>();
                // 遍历list的长度，将MyAdapter中的map值全部设为true
                for (int i = 0; i < adatperDataList.size(); i++) {
                    sa.getIsSelected().put(i, isChecked);
                    //adatperDataList.get(i).put("" + i, isChecked);
                    if (isChecked == true) {
                        isSelectList.add(cgglCgList.get(i));
//                        if (sa.getIamountUpdated().get(i) == null) {
//                            isSelectList.remove(cgglCgList.get(i));
//                        }
                    } else {
                        isSelectList.removeAll(isSelectList);
                    }
                }
                sa.notifyDataSetChanged();
                amount = sa.sumAmount(adatperDataList);
                if (amount == 0.00) {
                    tv_cgdorder.setText("生成");
                } else {
                    tv_cgdorder.setText("生成（含税金额：" + amount + "元）");
                }
            }
        });

        tv_cgdorder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cgdd_scsh();
            }
        });
    }

    public void showMyDialog(final int position) {
        final View view = LayoutInflater.from(this).inflate(R.layout.basenvo_cgglscsh, null);
        final TextView shuilv = (TextView) view.findViewById(R.id.shuilv);
        final TextView shuie = (TextView) view.findViewById(R.id.shuie);
        final EditText iquantity = (EditText) view.findViewById(R.id.iquantity);
        final EditText inum = (EditText) view.findViewById(R.id.inum);
        final EditText iprice = (EditText) view.findViewById(R.id.iprice);
        final EditText iamount = (EditText) view.findViewById(R.id.iamount);
        final EditText hsipric = (EditText) view.findViewById(R.id.hsipric);
        final EditText hsiamount = (EditText) view.findViewById(R.id.hsiamount);
        EditText cdefine2_edit = (EditText) view.findViewById(R.id.cdefine2);
        EditText cdefine3_edit = (EditText) view.findViewById(R.id.cdefine3);
        setPricePoint(iquantity);
        setPricePoint(iprice);
        setPricePoint(iamount);
        setPricePoint(hsipric);
        setPricePoint(hsiamount);

        String cdefine2 = cgglCgList.get(position).getS_cdefine2();
        String cdefine3 = cgglCgList.get(position).getS_cdefine3();
        final String dialogiquantity = Basenvo.customFormat("#####0.00##", cgglCgList.get(position).getIquantity_flag());
        dialogdata = new HashMap<String, Object>();
        dialogdata.put("dialogsl", sl);
        shuilv.setText(sl);
        dialogdata.put("dialogyssl", yssl);
        iquantity.setText(dialogiquantity);
        inum.setText(cgglCgList.get(position).getInum());
        iprice.setText(cgglCgList.get(position).getNotaxprice());
        iamount.setText(cgglCgList.get(position).getNotaxamount());
        hsipric.setText(cgglCgList.get(position).getIprice());
        hsiamount.setText(cgglCgList.get(position).getIamount());
//        String dialoghsiamount = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
//                "" + Double.parseDouble(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
//                        cgglCgList.get(position).getIprice()), 12, 1)) * Double.parseDouble(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
//                        cgglCgList.get(position).getIquantity_jy()), 12, 0))), 12, 1);
        if (cgglCgList.get(position).getCinva_unit() == "") {
            inum.setEnabled(false);
        }
        String dialogshuie = "" + Double.parseDouble(cgglCgList.get(position).getIamount()) /
                (1 + Double.parseDouble(yssl)) * Double.parseDouble(sl);
        shuie.setText(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                dialogshuie), 12, 1));
        cdefine2_edit.setText(cdefine2);
        cdefine3_edit.setText(cdefine3);

        iquantity.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setIquantityChange(view, position);
                hintKey();
                return false;
            }
        });

        inum.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setInumChange(view, position);
                hintKey();
                return false;
            }
        });

        iprice.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setIpriceChange(view, dialogdata, position);
                hintKey();
                return false;
            }
        });

        iamount.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setIamountChange(view, dialogdata, position);
                hintKey();
                return false;
            }
        });

        hsipric.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setHsipriceChange(view, dialogdata, position);
                hintKey();
                return false;
            }
        });

        hsiamount.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                setHsiamountChange(view, dialogdata, position);
                hintKey();
                return false;
            }
        });

        iquantity.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "0";
                } else {
                    setIquantityChange(view, position);
                }
            }
        });

        inum.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "1";
                } else {
                    setInumChange(view, position);
                }
            }
        });

        iprice.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "2";
                } else {
                    setIpriceChange(view, dialogdata, position);
                }
            }
        });

        iamount.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "3";
                } else {
                    setIamountChange(view, dialogdata, position);
                }
            }
        });

        hsipric.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "4";
                } else {
                    setHsipriceChange(view, dialogdata, position);
                }
            }
        });

        hsiamount.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "5";
                } else {
                    setHsiamountChange(view, dialogdata, position);
                }
            }
        });

//        cdefine2_edit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
//            @Override
//            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
//                changeCdefine2(view, position);
//                hintKey();
//                return false;
//            }
//        });

        cdefine2_edit.setOnFocusChangeListener(new View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "6";
                } else {
                    changeCdefine2(view, position);
                }
            }
        });

//        cdefine3_edit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
//            @Override
//            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
//                changeCdefine3(view, position);
//                hintKey();
//                return false;
//            }
//        });

        cdefine3_edit.setOnFocusChangeListener(new View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                    flag = "7";
                } else {
                    changeCdefine3(view, position);
                }
            }
        });

        AlertDialog dialog = new AlertDialog.Builder(Cggl_sh_index.this)
                //.setIcon(R.mipmap.icon)//设置标题的图片
                .setTitle("明细")//设置对话框的标题
                .setView(view)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (flag == "0") {
                            setIquantityChange(view, position);
                        } else if (flag == "1") {
                            setInumChange(view, position);
                        } else if (flag == "2") {
                            setIpriceChange(view, dialogdata, position);
                        } else if (flag == "3") {
                            setIamountChange(view, dialogdata, position);
                        } else if (flag == "4") {
                            setHsipriceChange(view, dialogdata, position);
                        } else if (flag == "5") {
                            setHsiamountChange(view, dialogdata, position);
                        } else if (flag == "6") {
                            changeCdefine2(view, position);
                        } else if (flag == "7") {
                            changeCdefine3(view, position);
                        }
                        amount = sa.sumAmount(adatperDataList);
                        if (amount == 0.00) {
                            tv_cgdorder.setText("生成");
                        } else {
                            tv_cgdorder.setText("生成（含税金额：" + amount + "元）");
                        }
                        hintKey();
                        dialog.dismiss();
                    }
                }).create();
        dialog.show();
    }

    private void setIquantityChange(View view, int position) {
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        EditText hsiprice_edit = (EditText) view.findViewById(R.id.hsipric);
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        EditText inum_edit = (EditText) view.findViewById(R.id.inum);
        String changeIquantity = iquantity_edit.getText().toString();
        if (Double.parseDouble(changeIquantity) > Double.parseDouble(cgglCgList.get(position).getIquantity_jy())) {
            AbToastUtil.showToast(Cggl_sh_index.this, "必须小于结余数量！");
            return;
        }
        String iprice = iprice_edit.getText().toString();
        String hsiprice = hsiprice_edit.getText().toString();
        String iamount = "" + Double.parseDouble(set0(changeIquantity)) *
                Double.parseDouble(iprice);
        String hsiamount = "" + Double.parseDouble(set0(changeIquantity)) *
                Double.parseDouble(hsiprice);
        iamount_edit.setText(iamount);
        hsiamount_edit.setText(hsiamount);
        String invexchrate = cgglCgList.get(position).getIinvexchrate();
        String inum = "";
        if (!"0".equals(invexchrate)) {
            if ("0".equals(cgglCgList.get(position).getBinvexchtype())) {
                inum = "" + Double.parseDouble(set0(changeIquantity)) * Double.parseDouble(invexchrate);
                inum_edit.setText(inum);
            } else if ("1".equals(cgglCgList.get(position).getBinvexchtype())) {
                inum = "" + Double.parseDouble(set0(changeIquantity)) / Double.parseDouble(invexchrate);
                inum_edit.setText(inum);
            }
        }

        cgglCgList.get(position).setIquantity_sh(changeIquantity);
        cgglCgList.get(position).setIquantity_flag(changeIquantity);
        cgglCgList.get(position).setNotaxamount(iamount);
        cgglCgList.get(position).setIamount(hsiamount);
        cgglCgList.get(position).setInum(inum);
        dataListForInit.get(position).put("iquantity", changeIquantity);
        dataListForInit.get(position).put("hsiamount", hsiamount);
        dataListForInit.get(position).put("inum", inum);
        sa.notifyDataSetChanged();
        //}
    }

    private void setInumChange(View view, int position) {
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        EditText hsiprice_edit = (EditText) view.findViewById(R.id.hsipric);
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        EditText inum_edit = (EditText) view.findViewById(R.id.inum);
        String iprice = iprice_edit.getText().toString();
        String hsiprice = hsiprice_edit.getText().toString();
        String changeInum = inum_edit.getText().toString();
        String invexchrate = cgglCgList.get(position).getIinvexchrate();
        String iquantity = "";
        String iamount = "";
        String hsiamount = "";
        if (!"0".equals(invexchrate)) {
            if ("0".equals(cgglCgList.get(position).getBinvexchtype())) {
                iquantity = "" + Double.parseDouble(set0(changeInum)) / Double.parseDouble(invexchrate);
                iquantity_edit.setText(iquantity);
            } else if ("1".equals(cgglCgList.get(position).getBinvexchtype())) {
                iquantity = "" + Double.parseDouble(set0(changeInum)) * Double.parseDouble(invexchrate);
                iquantity_edit.setText(iquantity);
            }
            iamount = "" + Double.parseDouble(iquantity) * Double.parseDouble(iprice);
            hsiamount = "" + Double.parseDouble(iquantity) * Double.parseDouble(hsiprice);
            iamount_edit.setText(iamount);
            hsiamount_edit.setText(hsiamount);
        }

        cgglCgList.get(position).setInum(changeInum);
        cgglCgList.get(position).setIquantity_sh(iquantity);
        cgglCgList.get(position).setNotaxamount(iamount);
        cgglCgList.get(position).setIamount(hsiamount);
        dataListForInit.get(position).put("inum", changeInum);
        dataListForInit.get(position).put("iquantity", iquantity);
        dataListForInit.get(position).put("hsiamount", hsiamount);
        sa.notifyDataSetChanged();
    }

    private void setIpriceChange(View view, Map<String, Object> dialogdata, int position) {
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText hsipric_edit = (EditText) view.findViewById(R.id.hsipric);
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        TextView shuie_tv = (TextView) view.findViewById(R.id.shuie);
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        String changeIprice = iprice_edit.getText().toString();
        String iquantity = iquantity_edit.getText().toString();
        String iamount = "" + Double.parseDouble(set0(changeIprice)) * Double.parseDouble(iquantity);
        String shuie = Basenvo.space_add(Basenvo.customFormat("#####0.00##", "" +
                Double.parseDouble(set0(iamount)) *
                        Double.parseDouble((String) dialogdata.get("dialogsl")) /
                        (1 + Double.parseDouble((String) dialogdata.get("dialogyssl")) -
                                Double.parseDouble((String) dialogdata.get("dialogsl")))), 12, 0);
        String hsiamount = "" + (Double.parseDouble(set0(iamount)) + Double.parseDouble(shuie));
        String hsiprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                "" + Double.parseDouble(hsiamount) / Double.parseDouble(iquantity)), 12, 0);
        iamount_edit.setText(iamount);
        shuie_tv.setText(shuie);
        hsiamount_edit.setText(hsiamount);
        hsipric_edit.setText(hsiprice);

        cgglCgList.get(position).setNotaxprice(changeIprice);
        cgglCgList.get(position).setNotaxamount(iamount);
        cgglCgList.get(position).setTax(shuie);
        cgglCgList.get(position).setIamount(hsiamount);
        cgglCgList.get(position).setIprice(hsiprice);
        dataListForInit.get(position).put("iquantity", iquantity);
        dataListForInit.get(position).put("hsiamount", hsiamount);
        dataListForInit.get(position).put("hsiprice", hsiprice);
        sa.notifyDataSetChanged();
    }

    private void setIamountChange(View view, Map<String, Object> dialogdata, int position) {
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        TextView shuie_tv = (TextView) view.findViewById(R.id.shuie);
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        EditText hsipric_edit = (EditText) view.findViewById(R.id.hsipric);
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        String iquantity = iquantity_edit.getText().toString();
        String changeIamount = iamount_edit.getText().toString();
        String shuie = Basenvo.space_add(Basenvo.customFormat("#####0.00##", "" + Double.parseDouble(set0(changeIamount)) *
                Double.parseDouble((String) dialogdata.get("dialogsl")) /
                (1 + Double.parseDouble((String) dialogdata.get("dialogyssl")) -
                        Double.parseDouble((String) dialogdata.get("dialogsl")))), 12, 0);
        String hsiamount = "" + (Double.parseDouble(set0(changeIamount)) + Double.parseDouble(shuie));
        String iprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                "" + Double.parseDouble(set0(changeIamount)) / Double.parseDouble(iquantity)), 12, 0);
        String hsiprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                "" + Double.parseDouble(hsiamount) / Double.parseDouble(iquantity)), 12, 0);
        //        double d1 = Double.parseDouble(iamount);
//        double d2 = Double.parseDouble(set0(Basenvo.space_add(Basenvo.customFormat("#####0.00##", changeIamount), 12, 1)));
//        if (d1 != d2) {
        iprice_edit.setText(iprice);
        shuie_tv.setText(shuie);
        hsiamount_edit.setText(hsiamount);
        hsipric_edit.setText(hsiprice);

        cgglCgList.get(position).setNotaxamount(changeIamount);
        cgglCgList.get(position).setNotaxprice(iprice);
        cgglCgList.get(position).setTax(shuie);
        cgglCgList.get(position).setIamount(hsiamount);
        cgglCgList.get(position).setIprice(hsiprice);
        dataListForInit.get(position).put("hsiamount", hsiamount);
        dataListForInit.get(position).put("hsiprice", hsiprice);
        sa.notifyDataSetChanged();
//        }
    }

    private void setHsipriceChange(View view, Map<String, Object> dialogdata, int position) {
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText hsipric_edit = (EditText) view.findViewById(R.id.hsipric);
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        TextView shuie_tv = (TextView) view.findViewById(R.id.shuie);
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        String iquantity = iquantity_edit.getText().toString();
        String changeHsiprice = hsipric_edit.getText().toString();
        String hsiamount = "" + (Double.parseDouble(set0(changeHsiprice)) * Double.parseDouble(iquantity));
        String shuie = Basenvo.space_add(Basenvo.customFormat("#####0.00##", "" +
                Double.parseDouble(hsiamount) / (1 +
                        Double.parseDouble((String) dialogdata.get("dialogyssl"))) *
                        Double.parseDouble((String) dialogdata.get("dialogsl"))), 12, 0);
        String iamount = "" + (Double.parseDouble(hsiamount) - Double.parseDouble(shuie));
        String iprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                "" + Double.parseDouble(hsiamount) / Double.parseDouble(iquantity)), 12, 0);
        iamount_edit.setText(iamount);
        shuie_tv.setText(shuie);
        hsiamount_edit.setText(hsiamount);
        iprice_edit.setText(iprice);

        cgglCgList.get(position).setIprice(changeHsiprice);
        cgglCgList.get(position).setIamount(hsiamount);
        cgglCgList.get(position).setTax(shuie);
        cgglCgList.get(position).setNotaxamount(iamount);
        cgglCgList.get(position).setNotaxprice(iprice);
        dataListForInit.get(position).put("hsiamount", hsiamount);
        dataListForInit.get(position).put("hsiprice", changeHsiprice);
        sa.notifyDataSetChanged();
    }

    private void setHsiamountChange(View view, Map<String, Object> dialogdata, int position) {
        EditText hsiamount_edit = (EditText) view.findViewById(R.id.hsiamount);
        EditText iamount_edit = (EditText) view.findViewById(R.id.iamount);
        EditText hsipric_edit = (EditText) view.findViewById(R.id.hsipric);
        TextView shuie_tv = (TextView) view.findViewById(R.id.shuie);
        EditText iprice_edit = (EditText) view.findViewById(R.id.iprice);
        EditText iquantity_edit = (EditText) view.findViewById(R.id.iquantity);
        String iquantity = iquantity_edit.getText().toString();
        String changeHsiamount = hsiamount_edit.getText().toString();
        String hsiprice = "" + (Double.parseDouble(set0(changeHsiamount)) / Double.parseDouble(iquantity));
        String shuie = Basenvo.space_add(Basenvo.customFormat("#####0.00##", "" +
                Double.parseDouble(set0(changeHsiamount)) / (1 +
                        Double.parseDouble((String) dialogdata.get("dialogyssl"))) *
                        Double.parseDouble((String) dialogdata.get("dialogsl"))), 12, 0);
        String iamount = "" + (Double.parseDouble(set0(changeHsiamount)) - Double.parseDouble(shuie));
        String iprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                "" + Double.parseDouble(iamount) / Double.parseDouble(iquantity)), 12, 0);
        iamount_edit.setText(iamount);
        shuie_tv.setText(shuie);
        hsipric_edit.setText(hsiprice);
        iprice_edit.setText(iprice);

        cgglCgList.get(position).setIamount(changeHsiamount);
        cgglCgList.get(position).setIprice(hsiprice);
        cgglCgList.get(position).setTax(shuie);
        cgglCgList.get(position).setNotaxamount(iamount);
        cgglCgList.get(position).setNotaxprice(iprice);
        dataListForInit.get(position).put("hsiamount", changeHsiamount);
        dataListForInit.get(position).put("hsiprice", hsiprice);
        sa.notifyDataSetChanged();
    }

    private void changeCdefine2(View view, int position) {
        EditText cdefine2_edit = (EditText) view.findViewById(R.id.cdefine2);
        String changeCdefine2 = cdefine2_edit.getText().toString();
        cdefine2_edit.setText(changeCdefine2);
        cgglCgList.get(position).setS_cdefine2(changeCdefine2);
        dataListForInit.get(position).put("data9", changeCdefine2);
        sa.notifyDataSetChanged();
    }

    private void changeCdefine3(View view, int position) {
        EditText cdefine3_edit = (EditText) view.findViewById(R.id.cdefine3);
        String changeCdefine3 = cdefine3_edit.getText().toString();
        cdefine3_edit.setText(changeCdefine3);
        cgglCgList.get(position).setS_cdefine3(changeCdefine3);
        dataListForInit.get(position).put("data10", changeCdefine3);
        sa.notifyDataSetChanged();
    }

    private String set0(String d) {
        if ("".equals(d)) {
            d = "0.00";
        }
        return d;
    }

    private void getcinvtaxrate(final int position) {
        String nameSpace = "http://service.test.com";
        String methodName = "getcinvtaxrate";
        String urlString = "http://" + InstorageURL.SERVERURL + BaseUrl_New;
        AbSoapParams params = new AbSoapParams();
        params.put("arg0", myApplication.getGs_ztid());
        params.put("arg1", myApplication.getGs_year());
        params.put("arg2", cgglCgList.get(position).getCinvcode());
        params.put("arg3", cgglCgList.get(position).getCvencode());
        mAbSoapUtil.call(urlString, nameSpace, methodName, params, new AbSoapListener() {
            //获取数据成功会调用这里
            @Override
            public void onSuccess(int statusCode, String content) {
                if (content != null) {
                    taxtype = content.replace(" ", "").split("计税类型编码=")[1].split(",计税类型名称")[0];
                    sl = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                            content.split(content.substring(content.indexOf("税率"),
                                    content.indexOf("税率") + 3))[1].split("，")[0]), 12, 1);
                    yssl = content.split("应税税率=")[1].split(";")[0];
                    String hsiamount = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                            "" + Double.parseDouble(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                                    cgglCgList.get(position).getIprice()), 12, 1)) * Double.parseDouble(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                                    cgglCgList.get(position).getIquantity_jy()), 12, 0))), 12, 0);
                    String shuie = "" + Double.parseDouble(hsiamount) /
                            (1 + Double.parseDouble(yssl)) * Double.parseDouble(sl);
                    String hsiprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                            cgglCgList.get(position).getIprice()), 12, 1);
                    cgglCgList.get(position).setTaxtype(taxtype);
                    cgglCgList.get(position).setTaxrate(sl);
                    cgglCgList.get(position).setTaxable_rate(yssl);
                    cgglCgList.get(position).setIamount(hsiamount);
                    cgglCgList.get(position).setTax(Basenvo.space_add(Basenvo.customFormat("#####0.00##",
                            shuie), 12, 1));
                    cgglCgList.get(position).setIprice(hsiprice);
                } else {
                    AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
                }
            }

            // 失败，调用
            @Override
            public void onFailure(int statusCode, String content,
                                  Throwable error) {
                AbDialogUtil.removeDialog(Cggl_sh_index.this);
                AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
            }

            // 开始执行前
            @Override
            public void onStart() {
                //显示进度框
                //AbDialogUtil.showProgressDialog(Cggl_sh_index.this, 0, "正在加载...");
            }

            // 完成后调用，失败，成功
            @Override
            public void onFinish() {
                //移除进度框
                AbDialogUtil.removeDialog(Cggl_sh_index.this);
            }
        });
    }

    //获取数据
    @Override
    public void getdata(int page) {
        //参数
        String nameSpace = "http://service.test.com";
        String methodName = "cggl_dd2cg_list";
        String urlString = "http://" + InstorageURL.SERVERURL + BaseUrl_New;
        AbSoapParams params = new AbSoapParams();
        params.put("arg0", User.uid);
        params.put("arg1", User.nickName);
        params.put("arg2", myApplication.getGs_ztid());
        params.put("arg3", myApplication.getGs_year());
        mAbSoapUtil.call(urlString, nameSpace, methodName, params, new AbSoapListener() {
            //获取数据成功会调用这里
            @Override
            public void onSuccess(int statusCode, String content) {
                adatperDataList.clear();
                dataListForInit = new ArrayList<Map<String, Object>>();
                if (content != null) {
                    cgglCgList = abXMLCgglscshlist.paraseCommentInfors(content);
                    for (int i = 0; i < cgglCgList.size(); i++) {
                        CgglCgList cgglsh = new CgglCgList();
                        cgglsh = cgglCgList.get(i);
                        String iprice = Basenvo.space_add(Basenvo.customFormat("#####0.00##", cgglsh.getIprice()), 12, 1);
                        String iquantity_jy = Basenvo.space_add(Basenvo.customFormat("#####0.00##", cgglsh.getIquantity_jy()), 12, 1);
                        String hsiamount = Basenvo.space_add(Basenvo.customFormat("#####0.00##", "" + Double.parseDouble(iprice) * Double.parseDouble(iquantity_jy)), 12, 1);
                        Map<String, Object> map = new HashMap<String, Object>();
                        map.put("index", (i + 1));
                        map.put("binvexchtype", cgglsh.getBinvexchtype());
                        map.put("cinvcode", cgglsh.getCinvcode());
                        map.put("cinvname", cgglsh.getCinvname());
                        map.put("cinvstd", cgglsh.getCinvstd());
                        map.put("cinvm_unit", cgglsh.getCinvm_unit());
                        map.put("cinva_unit", cgglsh.getCinva_unit());
                        map.put("cvencode", cgglsh.getCvencode());
                        map.put("cvenname", cgglsh.getCvenname());
                        map.put("cdepname", cgglsh.getCdepname());
                        map.put("iquantity", iquantity_jy);
                        map.put("inum", cgglsh.getInum());
                        map.put("hsiprice", "" + iprice);
                        map.put("hsiamount", "" + hsiamount);
                        map.put("data1", "        订购数量：" + Basenvo.space_add(Basenvo.customFormat("#####0.00##", cgglsh.getIquantity()), 12, 1));
                        map.put("data2", "                 单价：" + Basenvo.space_add(Basenvo.customFormat("#####0.00##", cgglsh.getIprice()), 12, 1));
                        map.put("data3", "                 金额：" + Basenvo.customFormat("#####0.00##", cgglsh.getIamount()));
                        map.put("data4", "        到货数量：" + Basenvo.customFormat("#####0.00##", cgglsh.getIquantity_sh()));
                        map.put("data5", "要求到货日期：" + cgglsh.getdDate_DH());
                        map.put("data6", "        订货日期：" + cgglsh.getDdate());
                        map.put("data7", "请购单流水号：" + cgglsh.getCvouchid());
                        map.put("data8", cgglsh.getS_cdefine1());
                        map.put("data9", cgglsh.getS_cdefine2());
                        map.put("data10", cgglsh.getS_cdefine3());
                        map.put("" + i, "false");
                        dataListForInit.add(map);
                        cgglsh.setNotaxamount(Basenvo.customFormat("#####0.00##", cgglsh.getIamount()));
                        cgglsh.setNotaxprice(Basenvo.space_add(Basenvo.customFormat("#####0.00##", cgglsh.getIprice()), 12, 1));
                        cgglsh.setIquantity_flag(iquantity_jy);
                        sa.getIsSelected().put(i, false);
                        getcinvtaxrate(i);
                    }
                    if (isSelectList.size() > 0) {
                        for (int j = 0; j < isSelectList.size(); j++) {
                            isSelectList.remove(j);
                            j--;
                        }
                    }
                } else {
                    AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
                }
                toolDataProvider.initData(dataListForInit);
                loadList();
            }

            // 失败，调用
            @Override
            public void onFailure(int statusCode, String content,
                                  Throwable error) {
                AbDialogUtil.removeDialog(Cggl_sh_index.this);
                AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
            }

            // 开始执行前
            @Override
            public void onStart() {
                //显示进度框
                AbDialogUtil.showProgressDialog(Cggl_sh_index.this, 0, "正在加载...");
            }

            // 完成后调用，失败，成功
            @Override
            public void onFinish() {
                //移除进度框
                AbDialogUtil.removeDialog(Cggl_sh_index.this);
            }
        });
    }

    public void getRdStyle() {
        String nameSpace = "http://service.test.com";
        String methodName = "rdstylelist";
        String urlString = "http://" + InstorageURL.SERVERURL + BaseUrl_New;
        AbSoapParams params = new AbSoapParams();
        params.put("arg0", myApplication.getGs_ztid());
        params.put("arg1", myApplication.getGs_year());
        params.put("arg2", "1");
        mAbSoapUtil.call(urlString, nameSpace, methodName, params, new AbSoapListener() {
            //获取数据成功会调用这里
            @Override
            public void onSuccess(int statusCode, String content) {
                if (content != null) {
                    list_rklb.clear();
                    list_crdcode.clear();
                    List<String> list = new ArrayList<String>();
                    content = content.replace("RdStyleList=anyType", "#=#");
                    String[] strs = content.split("#=");
                    for (int i = 0; i < strs.length; i++) {
                        if (strs[i].contains("#")) {
                            list.add(strs[i].replace("#", "").trim());
                        }
                    }
                    for (int i = 0; i < list.size(); i++) {
                        list.set(i, list.get(i).replace(" ", ""));
                        if (i == list.size() - 1) {
                            list.set(i, list.get(i).replace("};};}", "};"));
                        }
                        list.set(i, list.get(i).replace("=", "\":\""));
                        list.set(i, list.get(i).replace(";};", "\"}"));
                        list.set(i, list.get(i).replace(";", "\",\""));
                        list.set(i, list.get(i).replace("{", "{\""));
                        try {
                            JSONObject dataJson = new JSONObject(list.get(i));
                            list_crdcode.add(dataJson.getString("crdcode"));
                            list_rklb.add(dataJson.getString("crdname"));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    adapter_rklb.notifyDataSetChanged();
                } else {
                    AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
                }
            }

            // 失败，调用
            @Override
            public void onFailure(int statusCode, String content,
                                  Throwable error) {
                AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
            }

            // 开始执行前
            @Override
            public void onStart() {
                //显示进度框
            }

            // 完成后调用，失败，成功
            @Override
            public void onFinish() {
                //移除进度框
            }
        });
    }

    public void getWareHouse() {
        String nameSpace = "http://service.test.com";
        String methodName = "warehouselist";
        String urlString = "http://" + InstorageURL.SERVERURL + BaseUrl_New;
        AbSoapParams params = new AbSoapParams();
        params.put("arg0", myApplication.getGs_ztid());
        params.put("arg1", myApplication.getGs_year());
        params.put("arg2", User.uid);
        params.put("arg3", "000");
        mAbSoapUtil.call(urlString, nameSpace, methodName, params, new AbSoapListener() {
            //获取数据成功会调用这里
            @Override
            public void onSuccess(int statusCode, String content) {
                list_shck.clear();
                list_cwhcode.clear();
                if (content != null) {
                    List<String> list = new ArrayList<String>();
                    content = content.replace("WareHouse=anyType", "#=#");
                    String[] strs = content.split("#=");
                    for (int i = 0; i < strs.length; i++) {
                        if (strs[i].contains("#")) {
                            list.add(strs[i].replace("#", "").trim());
                        }
                    }
                    for (int i = 0; i < list.size(); i++) {
                        list.set(i, list.get(i).replace(" ", ""));
                        if (i == list.size() - 1) {
                            list.set(i, list.get(i).replace("};};}", "};"));
                        }
                        list.set(i, list.get(i).replace("=", "\":\""));
                        list.set(i, list.get(i).replace(";};", "\"}"));
                        list.set(i, list.get(i).replace(";", "\",\""));
                        list.set(i, list.get(i).replace("{", "{\""));
                        try {
                            JSONObject dataJson = new JSONObject(list.get(i));
                            list_shck.add(dataJson.getString("cwhname"));
                            list_cwhcode.add(dataJson.getString("cwhcode"));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    isbegin = true;
                } else {
                    AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
                }
            }

            // 失败，调用
            @Override
            public void onFailure(int statusCode, String content,
                                  Throwable error) {
                AbToastUtil.showToast(Cggl_sh_index.this, R.string.sqlerrormsg);
            }

            // 开始执行前
            @Override
            public void onStart() {
                //显示进度框
            }

            // 完成后调用，失败，成功
            @Override
            public void onFinish() {
                //移除进度框
            }
        });
    }

    public void cgdd_scsh() {
        if (!(isSelectList.size() > 0)) {
            AbToastUtil.showToast(getApplicationContext(), "请选择数据！");
            return;
        }
        //参数
        String urlString = "http://" + InstorageURL.SERVERURL
                + BaseUrl_New;
        String[] parms = {"cvouchtype", "cwhcode", "crdincode", "usercode", "username", "cacc_id", "iyear", "gs_sj"};
        String[] vals = {"1", cwhcode, crdcode, User.uid, User.nickName, (String) myApplication.getGs_ztid(), (String) myApplication.getGs_year(), myApplication.getGs_sj()};
        //生成xml
        BuildCgglscshXMLService service = new BuildCgglscshXMLService();
        String xmlstring = service.buildXML(isSelectList, "cggl_dd2sh", InstorageURL.NAME_SPACE, parms, vals, "in" + vals.length);
        mAbSoapUtil.xmlCall(urlString, InstorageURL.NAME_SPACE, "cggl_dd2sh", xmlstring, new AbSoapUtil.WebServiceCallBack() {
            @Override
            public void onSucced(String result) {
                if (result != null) {
                    String str = result.split("<ns1:out>")[1].split("</ns1:out>")[0];
                    getdata(0);
                    AbToastUtil.showToast(getApplicationContext(), str);
                    tv_cgdorder.setText("生成");
                } else {
                    AbToastUtil.showToast(getApplicationContext(), R.string.sqlerrormsg);
                }
            }

            @Override
            public void onFailure(String result) {
                AbToastUtil.showToast(getApplicationContext(), R.string.sqlerrormsg);
                //swipeRefreshLayout.setRefreshing(false);
            }
        });
    }


    //删除
//    public void mrqgd_del(View v) {
//        mrqgdorderact("mrqgd_order_del", "删除定价");
//    }
//
//    //叫货
//    public void cgd_order(View v) {
//        mrqgdorderact("mrqgd_order_ok", "叫货");
//    }

    //删除和保存定价的动作函数
//    public void mrqgdorderact(String methodName, final String ctypetext) {
//        Boolean ischoose = false;
//        String iprice = "";
//        // 遍历list的长度，判断是否选中
//        HashMap<Integer, Boolean> selectlist = sa.getIsSelected();
//        //获取单价修改状态
//        HashMap<Integer, String> IpriceUpdated = sa.getIpriceUpdated();
//        //先判断存货是否选择,同时还要更改list中的选择标记
//        for (int i = 0; i < selectlist.size(); i++) {
//            MrqgdDjList mrqgd = (MrqgdDjList) mrqgdlists.get(i);
//            if (selectlist.get(i)) {
//                ischoose = true;
//                mrqgd.setBchecked("1");
//                iprice = IpriceUpdated.get(i);
//                mrqgd.setIprice(iprice);
//                mrqgd.setIamount(Basenvo.customFormat("#####0.00##", Double.valueOf(mrqgd.getiQuantity()) * Double.valueOf(iprice)));
//            } else {
//                mrqgd.setBchecked("0");
//            }
//        }
//        if (!ischoose) {
//            AbToastUtil.showToast(getApplicationContext(), "请选择需要" + ctypetext + "的存货");
//            return;
//        }
//        //刷新列表
//        String urlString = "http://" + InstorageURL.SERVERURL
//                + BaseUrl_New;
//        String[] parms = {"user", "cacc_id", "iyear", "ddate", "ddate_dh", "cvencode"};
//        String[] vals = {User.uid, (String) myApplication.getGs_ztid(), (String) myApplication.getGs_year(), mrqgds.getdDate(), mrqgds.getdDhDate(), mrqgds.getCvencode()};
//        String url = (String) myApplication.getGs_url();
//        //生成xml
//        BuildMrqgdXMLService service = new BuildMrqgdXMLService();
//        String xmlstring = service.buildXML(methodName, InstorageURL.NAME_SPACE, parms, vals, "in" + parms.length, mrqgdlists);
//        mAbSoapUtil.xmlCall(urlString, InstorageURL.NAME_SPACE, methodName, xmlstring, new AbSoapUtil.WebServiceCallBack() {
//            @Override
//            public void onSucced(String result) {
//                adatperDataList.clear();
//                ArrayList<Map<String, Object>> dataListForInit = new ArrayList<Map<String, Object>>();
//                if (result != null) {
//                    //解析xml文件,返回列表
//                    mrqgdlists = XMLMrqgdlist.paraseCommentInfors(result);
//                    AbToastUtil.showToast(getApplicationContext(), ctypetext + "成功!");
//                    if (mrqgdlists.size() > 0) {
//                        for (int i = 0; i < mrqgdlists.size(); i++) {
//                            MrqgdDjList mrqgds1 = new MrqgdDjList();
//                            mrqgds1 = mrqgdlists.get(i);
//                            //                            aaa.add(item.getPropertyAsString(0));
//                            Map<String, Object> map = new HashMap<String, Object>();
//                            map.put("index", (i + 1));
//                            map.put("cdepname", mrqgds1.getCdepname());
//                            map.put("cinvname", mrqgds1.getcInvname());
//                            map.put("cinvstd", mrqgds1.getcInvstd());
//                            map.put("cinvunit", mrqgds1.getcInvm_unit());
//                            map.put("iquantity", mrqgds1.getiQuantity());
//                            map.put("iprice", mrqgds1.getIprice());
//                            dataListForInit.add(map);
//                            sa.getIsSelected().put(i, true);
//                        }
//                        toolDataProvider.initData(dataListForInit);
//                        loadList();
//                        //mHandler.sendEmptyMessage(LIST_GET_FIRST_PAGE); //加载完毕发送指令显示第一页
//                        //swipeRefreshLayout.setRefreshing(false);
//                    } else {
//                        //增加一个全部删除或者全部叫货的判断
//                        setResult(R.layout.layout_mrqgd_orderdetail / 200000);  //设置返回结果
//                        finish();
//                    }
//                } else {
//                    AbToastUtil.showToast(getApplicationContext(), ctypetext + "失败!数据库错误");
//                }
//            }
//
//            @Override
//            public void onFailure(String result) {
//                AbToastUtil.showToast(getApplicationContext(), ctypetext + "失败!数据库错误");
//                //swipeRefreshLayout.setRefreshing(false);
//            }
//        });
//    }
}
